<?php

/**
 *Simple CRUD Code Generator
 *Email:  support@crazedcoders.com
 *Website: http://www.crazedcoders.com/
 *Copyright (C) 2007 CrazedCoders
 *
 *This program is free software: you can redistribute it and/or modify
 *it under the terms of the GNU General Public License as published by
 *the Free Software Foundation, either version 3 of the License, or
 *(at your option) any later version.
 *
 *THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *SOFTWARE.
 *
 *You should have received a copy of the GNU General Public License
 *along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class StdFunc {
	static $dbName = 'DBNAME_PLACEHOLDER';
	static $dbHost = 'DBHOST_PLACEHOLDER';
	static $dbUser = 'DBUSER_PLACEHOLDER';
	static $dbPass = 'DBPASS_PLACEHOLDER';

	static $LOGFILE= 'log.txt';

	public static function array_clone( $array ) {
		$new = array();
		foreach( $array as $key=>$value ) {
			$new[$key] = $value;
		}
		return( $new );
	}

	static function logString() {
		$argc = func_num_args();
		if( $argc > 0 ) {
			$str = func_get_arg(0);
		}
		if( $argc > 1 ) {
			$func = func_get_arg(1);
		}
		$fh = fopen( StdFunc::$LOGFILE, "a" );
		fwrite( $fh, (date("c"))."; ".$_SERVER['REMOTE_ADDR']
				."; [".$func."] ".$str."\n" );
		fclose( $fh );
	}

	static function mssql_insert_id( $link )
	{
		$result = @mssql_query("SELECT @@identity", $link);
		if (!$result) return -1;
		return mssql_result($result, 0, 0);
	}
}
?>
